package bsh.dyn;

import bsh.CompiledScript;

/**
 * A transformation is a modification that can be done in order to call a method / constructor - usually primitive wrapper unboxing,
 * primitive type widening, etc
 * 
 * @author takeshi
 */
public interface Transformation {

    /**
     * A weight of the transformation is used to tie break between two invocable methods
     * 
     * @return int
     */
    int getWeight();

    /**
     * The type that this transformation transforms to.
     * 
     * @return {@link ActualParameter}
     */
    ActualParameter getTransformationTarget();

    /**
     * Returns true if this tranformation can be applied to the given parameter type
     * 
     * @param parameter {@link ActualParameter}
     * @return boolean
     */
    boolean acceptsType(ActualParameter parameter);

    /**
     * Transforms the given object
     * 
     * @param object Object
     * @param script TODO
     * @return Object
     */
    Object transform(Object object, CompiledScript script);

    /**
     * Returns true if this tranformation can generate bytecode for JIT compilation.
     * 
     * @return boolean
     */
    boolean isCompilable();

}